package com.ymatou.iapi.godmch.service;

import org.json.JSONException;
import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.ymatou.iapi.godmch.parameter.AgentDetailInfo;
import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;
/**
*获取商户配置Call
*FreeMaker Template自动生成代码
*/
public class getConfigCall extends YmatouBaseCall{
	private static String opurl ="api/config/getConfig";
	
	public getConfigCall() {
		super(EnvSetup.getSystemUrl("godmch_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	 public String getStatusCode1()
		{
		  return getString("status");
		}
		
		 public String getMessage()
		{
		 return getString("msg");
		}
		
		
		public createIndepMchBean getResult() {
			createIndepMchBean result =null;
			try {
				result = (createIndepMchBean) new Gson().fromJson(getString("result").toString(), new TypeToken<createIndepMchBean>() {}.getType());
			} catch (Exception e) {
				//没获取到就是null
//				e.printStackTrace();
			}
			return result;
		}
		
		
		public Integer getMchId() {
			Integer result =null;
			try {
				result = new JSONObject(getString("result").toString()).getInt("mchId");
			} catch (Exception e) {
				//没获取到就是null
//				e.printStackTrace();
			}
			return result;
		}
	
}